package com.student.controller;

import com.student.VO.SnackVO;
import com.student.dto.ResponseDto;
import com.student.pojo.SnackOrder;
import com.student.service.SnackOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: makeups
 * @BelongsPackage: com.student.controller
 * @Author: 小徐
 * @CreateTime: 2024-12-21 20:04
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("order")
public class SnackOrderController {
    @Autowired
    private SnackOrderService snackOrderService;

    //    获取所有的订单信息
    @RequestMapping("getAllOrder")
    public ResponseDto getAllOrder(@RequestBody SnackOrder snackOrder) {
        System.err.println(snackOrder);
        return snackOrderService.getAllOrder(snackOrder);
//        return null;
    }

    //    获取所有的订单信息
    @RequestMapping("getAllOrderPerson")
    public ResponseDto getAllOrderPerson(@RequestBody SnackOrder snackOrder) {
        System.err.println(snackOrder);
        return snackOrderService.getAllOrderPerson(snackOrder);

    }    //    获取所有的订单信息
    @RequestMapping("getAllOrderMannger")
    public ResponseDto getAllOrderMannger(@RequestBody SnackOrder snackOrder) {
        System.err.println(snackOrder);
        return snackOrderService.getAllOrderMannger(snackOrder);

    }





//      修改配送状态

    @RequestMapping("updateStatics")
    public ResponseDto updateStatics(@RequestParam("status") Integer status, @RequestParam("id") Integer id, @RequestParam("adminId") Integer adminId) {
        System.err.println("管理员：" + adminId);
        return snackOrderService.updateStatics(status, id, adminId);
    }

    //    删除订单
    @RequestMapping("deleteOrder")
    public ResponseDto deleteOrder(@RequestParam("id") Integer id) {
        return snackOrderService.deleteOrder(id);
    }

    //  添加订单信息
    @RequestMapping("addOrderPerson")
    public ResponseDto addOrderPerson(@RequestParam("id") Integer id,
                                      @RequestParam("tatol") double tatol,
                                      @RequestParam("address") String address,
                                      @RequestParam("phone") String phone,
                                      @RequestParam("name") String name,
                                      @RequestParam("price") double price,
                                      @RequestParam("proID") Integer proID,
                                      @RequestParam("num") Integer num) {

        return snackOrderService.addOrderPerson(id, tatol, address, phone, name, price, proID, num);
    }

    //  添加订单信息
    @RequestMapping("addTatolMoney")
    public ResponseDto addTatolMoney(@RequestParam("id") Integer id,
                                     @RequestParam("tatol") double tatol,
                                     @RequestParam("address") String address,
                                     @RequestParam("phone") String phone,
                                     @RequestParam("name") String name) {

        return snackOrderService.addTatolMoney(id, tatol, address, phone, name);
    }

    //  添加订单信息
    @RequestMapping("addOrderPersonTotal")
    public ResponseDto addOrderPersonTotal(@RequestParam("id") Integer id,
                                           @RequestParam("tatol") double tatol,
                                           @RequestParam("address") String address,
                                           @RequestParam("phone") String phone,
                                           @RequestParam("name") String name,
                                           @RequestParam("price") double price,
                                           @RequestParam("proID") Integer proID,
                                           @RequestParam("num") Integer num,
                                           @RequestParam("number") Integer number,
                                           @RequestParam("cardIds") Integer cardIds,
                                           @RequestParam("orderID") Integer orderID
    ) {

        return snackOrderService.addOrderPersonTotal(id, tatol, address, phone, name, price, proID, num, number, cardIds, orderID);
    }

    //    /删除购物车的信息
    @RequestMapping("deleteCard")

    public ResponseDto deleteCard(@RequestParam("id") Integer id) {
        return snackOrderService.deleteCard(id);
    }

    //  添加评论
    @RequestMapping("addTaking")
    public ResponseDto addTaking(@RequestParam("id") Integer id, @RequestParam("taking") String taking) {
        return snackOrderService.addTaking(id, taking);
    }

    @RequestMapping("updateStaticsUser")
    public ResponseDto updateStaticsUser(@RequestParam("id") Integer id, @RequestParam("status") Integer status) {
        return snackOrderService.updateStaticsUser(id, status);
    }




}